<script setup>
import {ref, reactive} from 'vue';
import {ElMessage} from 'element-plus';
// 获取开放的城市列表
import {updateProductApi} from '@/service/member.js';

const productForm = ref({
  member_id: '',
  event_date: '',
  budget: '',
  table_amount: '',
});

const visible = ref(false);
// open dialog
const openDialog = (row) => {
  visible.value = true;
  productForm.value = row;
};

// 关闭弹窗
const closeDialog = () => {
  visible.value = false;
  // init form
  productForm.value = {
    member_id: '',
    event_date: '',
    budget: '',
    table_amount: '',
  };
};

// 提交表单
const submitForm = () => {
  updateProductApi(productForm.value).then(res => {
    if (res.code === 200) {
      closeDialog();
      ElMessage.success(res.msg);
    } else {
      ElMessage.error(res.msg);
    }
  });
};

defineExpose({
  openDialog
});

</script>

<template>
<el-dialog title="编辑产品" v-model="visible" width="30%" append-to-body>
  <el-form :model="productForm" ref="form" label-width="100px" label-position="top">
    <el-form-item label="婚期日期" prop="event_date">
      <el-input v-model="productForm.event_date" placeholder="请输入预算"></el-input>
    </el-form-item>
    <el-form-item label="预算" prop="budget">
      <el-input v-model="productForm.budget" placeholder="请输入预算"></el-input>
    </el-form-item>
    <el-form-item label="桌数" prop="table_amount">
      <el-input v-model="productForm.table_amount" placeholder="请输入桌数"></el-input>
    </el-form-item>
  </el-form>
  <span slot="footer" class="dialog-footer">
    <el-button @click="closeDialog">取 消</el-button>
    <el-button type="primary" @click="submitForm">确 定</el-button>
  </span>
</el-dialog>
</template>

<style scoped>

</style>
